package com.ccsu.joysport.controller;


import com.ccsu.joysport.entity.Info;
import com.ccsu.joysport.service.setInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/ccsu/admin/info")
public class setInfoController {
    @Autowired
    private setInfoService setInfoService;

    @GetMapping
    public List<Info> getAllNews() {
        return setInfoService.getAllNews();
    }

    @PostMapping
    public Info addNews(@RequestBody Info news) {
        return setInfoService.addNews(news);
    }

    @DeleteMapping("/{id}")
    public void deleteNews(@PathVariable Long id) {
        setInfoService.deleteNews(id);
    }

    @PutMapping("/{id}")
    public Info updateNews(@PathVariable Long id, @RequestBody Info updatedNews) {
        return setInfoService.updateNews(id, updatedNews);
    }
}
